package com.codingke.codingbookstore.ui;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.codingke.codingbookstore.R;
import com.codingke.codingbookstore.vo.User;

import cn.bmob.v3.BmobUser;

@Deprecated
public class SettingsUsernameActivity extends BaseActivity {

    private EditText editText_username;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings_username);
        editText_username = (EditText) findViewById(R.id.editText_username);

    }

    public void setUsernameClick(View view){
        updateUsername();
    }

    /**
     * 更新
     */
    private void updateUsername() {
        String username = editText_username.getText().toString();
        if(TextUtils.isEmpty(username)){
            return;
        }

        User currentUser = BmobUser.getCurrentUser(this, User.class);
        currentUser.setUsername(username);
        currentUser.update(this);
        showToast("会员名已设置");
        finish();
    }
}
